package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlRoomType;
import com.ruoyi.hotel.service.IHlRoomTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间类型Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hltype")
public class HlRoomTypeController extends BaseController
{
    @Autowired
    private IHlRoomTypeService hlRoomTypeService;

    /**
     * 查询房间类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlRoomType hlRoomType)
    {
        startPage();
        List<HlRoomType> list = hlRoomTypeService.selectHlRoomTypeList(hlRoomType);
        return getDataTable(list);
    }

    /**
     * 导出房间类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:export')")
    @Log(title = "房间类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlRoomType hlRoomType)
    {
        List<HlRoomType> list = hlRoomTypeService.selectHlRoomTypeList(hlRoomType);
        ExcelUtil<HlRoomType> util = new ExcelUtil<HlRoomType>(HlRoomType.class);
        util.exportExcel(response, list, "房间类型数据");
    }

    /**
     * 获取房间类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(hlRoomTypeService.selectHlRoomTypeById(id));
    }

    /**
     * 新增房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:add')")
    @Log(title = "房间类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlRoomType hlRoomType)
    {
        return toAjax(hlRoomTypeService.insertHlRoomType(hlRoomType));
    }

    /**
     * 修改房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:edit')")
    @Log(title = "房间类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlRoomType hlRoomType)
    {
        return toAjax(hlRoomTypeService.updateHlRoomType(hlRoomType));
    }

    /**
     * 删除房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hltype:remove')")
    @Log(title = "房间类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hlRoomTypeService.deleteHlRoomTypeByIds(ids));
    }
}
